//HashTable.h
#ifndef HASHTABLE_H
#define HASHTABLE_H

#include "variables.h"
#include "vector.h"

class Container
{
	public:
		Vector* vector;
		long index;
		Container* next;

		Container(unchar* _values, int _size, long _index);
		~Container();
};

class HashItem
{
	public:
		int hashValue;
		Container* link;

		HashItem(int value);
		~HashItem();
		void add(unchar* values, int size, long index);
};

class HashTable
{
	private:
		//hash coding consts
		static const int multipier=31;
		static const int nHashes=500;
		int getHashCode(unchar* values, int size);
		//-----------------
		long limit;
		long containersCounter;
		HashItem* link[1000];
		int _HowManyBitsToWrite;

        void createHashTable();
        void deleteHashTable();
		void resetHashTable();
	public:
		HashTable();
		HashTable(int size);
		~HashTable();

		int initTable(int size);
		long contCounter() {return containersCounter;}
		void incBitsToWrite() {++_HowManyBitsToWrite;}
		int howManyBitsToWrite() {return _HowManyBitsToWrite;}
		int add(unchar* values, int size);
		long search(unchar* values, int size);
		int contcmp(Container *link, unchar* values, int size);
		long getLimit() {return limit;}
		void clear();
		
		void saveTable();
};

#endif
